<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<!-- the5fire的技术博客实例 -->
	<title>index_demo5</title>
	<script src="js/jquery.js"></script>
	<script src="js/underscore.js"></script>
	<script src="js/backbone.js"></script>
</head>
<body>
<a href="#actions">testActions</a>
<br>
<a href="#/posts/120">Post 120</a>
<br>
<a href="#/download/user/images/hey.gif">download gif</a>
<br>
<a href="#/dashboard/graph">Load Route/Action View</a>
	<script type="text/javascript">
	(function ($) {
		// var AppRouter = Backbone.Router.extend({

		// 	routes: {

		// 		"*actions" : "defaultRoute"

		// 	},

		// 	defaultRoute : function(actions){

		// 		alert("actions");

		// 	}

		// });

		// var app_router = new AppRouter;
		// // 历史管理
		// // Backbone.history.start()方法来初始化这个Router
		// Backbone.history.start();

		var AppRouter = Backbone.Router.extend({

		    routes: {

		        "posts/:id" : "getPost",

		        "*actions" : "defaultRoute",

		        "download/*path": "downloadFile",  //对应的链接为<a href="#/download/user/images/hey.gif">download gif</a>

		        ":route/:action": "loadView",      //对应的链接为<a href="#/dashboard/graph">Load Route/Action View</a>

		    },

		    getPost: function(id) {

		        alert(id);

		    },

		    defaultRoute : function(actions){

		        alert(actions);

		    },
    		downloadFile: function( path ){

                alert(path); // user/images/hey.gif

            },

            loadView: function( route, action ){
            	alert("loadView");
                alert(route + "_" + action); // dashboard_graph

            }

		});

		var app_router = new AppRouter;

		Backbone.history.start();

	})(jQuery);

	</script>
</body>
</html>